<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="num1">
    <input type="text" id="sign">
    <input type="text" id="num2">
    <input type="text" id="result">
    <button>计算</button>
    <script>
        var num1 = document.querySelector("#num1");
        var sign = document.querySelector("#sign");
        var num2 = document.querySelector("#num2");
        var result = document.querySelector("#result");
        var btn = document.querySelector("button");
        btn.onclick = function(){
            var n = Number(num1.value);
            var m = Number(num2.value);
            result.value = count(n,sign.value,m);
        }
        function count(n,s,m){
            switch(s){
                case "+": return n+m;break;
                case "-": return n-m;break;
                case "*": return n*m;break;
                case "/": return n/m;break;

            }
        }
    </script>
</body>
</html>